home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / tclX-6.4 / help / libraries / packagelib < prev    next >
Encoding:
Text File  |  1992-12-17  |  3.8 KB  |  77 lines

  1.  
  2.  
  3.      TCL PACKAGE LIBRARIES
  4.           Package libraries work like autoload, except that a package
  5.           library file can contain multiple independent Tcl packages.
  6.           A package is a collection of related Tcl procedures.
  7.  
  8.           The package library file is just a regular Unix text file,
  9.           editable with your favorite text editor, containing packages
  10.           of Tcl source code. The package library file name must have
  11.           the suffix .tlib.  An index file with the suffix created by
  12.           Tcl whenever it is out of date.
  13.  
  14.           The start of a package is delimited by:
  15.  
  16.                #@package: package_name proc1 [..procN]
  17.  
  18.           These lines must start in column one.  Everything between
  19.           the #@package: keyword and the next #@package: keyword or a
  20.           #@packend keyword, or the end of the file, becomes part of
  21.           the named package. The specified procedures, proc1..procN,
  22.           are the entry points of the package.  When a command named
  23.           in a package specification is executed and detected as an
  24.           unknown command, all code in the specified package will be
  25.           sourced.  This package should define all of the procedures
  26.           named on the package line, define any support procedures
  27.           required by the package and do any package-specific
  28.           initialization.  The #@packend keyword is useful to make
  29.           sure only the minimum required section of code is sourced.
  30.           Thus for example a large comment block at the beginning of
  31.           the next file won't be loaded.
  32.  
  33.           Care should be taken in defining package_name, as the first
  34.           package found in the path by with a given name is loaded.
  35.           This can be useful in developing new version of packages
  36.           installed on the system.
  37.  
  38.           For example, in a package source file, the presence of the
  39.           following line:
  40.  
  41.                #@package: directory_stack pushd popd dirs
  42.  
  43.           says that the text lines following that line in the package
  44.           file up to the next package line or the end of the file is a
  45.           package named directory_stack and that an attempt to execute
  46.           either pushd, popd or dirs when the routine is not already
  47.           defined will cause the directory_stack portion of the
  48.           package file to be loaded.
  49.  
  50.         PACKAGE INDEX FILES
  51.           A package library file has associated with it an index file
  52.           called a .tndx file.  The .tndx file contains the names of
  53.           the packages in the .tlib file, their addresses and lengths
  54.           within the .tlib file and the names of the functions that
  55.           are to cause the various packages to be autoloaded when an
  56.           attempt is made to execute them.
  57.  
  58.           The first time Tcl tries to execute a procedure where the
  59.           procedure doesn't exist and isn't an autoload, Tcl will
  60.           search along TCLPATH looking for any files ending in .tlib.
  61.           For each one it finds, it checks to see if there is a
  62.           corresponding file in the same directory ending in .tndx.
  63.           If the .tndx file doesn't exist, or if its date of last
  64.           modification is older than that of the .tlib file, the .tndx
  65.           is automatically (re)generated if possible.  If Tcl can't
  66.           regenerate the file (most likely due to file or directory
  67.           permission problems), an error occurs.  A .tndx file may
  68.           also be explicitly built with the buildpackageindex
  69.           procedure.
  70.  
  71.           Demand loading is also supported from indexes build by the
  72.           mkindex.tcl program, supplied with standard Tcl.  However,
  73.           init.tcl is not loaded.  Note that the info library command
  74.           is not used to locate libraries by this shell; the TCLPATH
  75.           variable is set by the default file and is used to locate
  76.           the libraries.
  77.